﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace NCEdu.Web.fileType
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int fileTypeId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(fileTypeId);
				}
			}
		}
			
	private void ShowInfo(int fileTypeId)
	{
		NCEdu.BLL.fileType bll=new NCEdu.BLL.fileType();
		NCEdu.Model.fileType model=bll.GetModel(fileTypeId);
		this.lblfileTypeId.Text=model.fileTypeId.ToString();
		this.txtfileName.Text=model.fileName;
		this.txtfileTypeName.Text=model.fileTypeName;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtfileName.Text.Trim().Length==0)
			{
				strErr+="fileName不能为空！\\n";	
			}
			if(this.txtfileTypeName.Text.Trim().Length==0)
			{
				strErr+="fileTypeName不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int fileTypeId=int.Parse(this.lblfileTypeId.Text);
			string fileName=this.txtfileName.Text;
			string fileTypeName=this.txtfileTypeName.Text;


			NCEdu.Model.fileType model=new NCEdu.Model.fileType();
			model.fileTypeId=fileTypeId;
			model.fileName=fileName;
			model.fileTypeName=fileTypeName;

			NCEdu.BLL.fileType bll=new NCEdu.BLL.fileType();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
